package com.xfhy.selectcity.select.viewmodel;

import android.text.TextUtils;

import com.ludashi.framework.ApplicationHolder;
import com.xfhy.selectcity.data.Area;
import com.xfhy.selectcity.data.AreaRepository;

import java.util.List;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.ViewModel;

/**
 * @author : xfhy
 * Create time : 2021/2/25 17:20
 * Description :
 */
public class SelectAreaViewModel extends ViewModel {

    private final AreaRepository mAreaRepository;

    public SelectAreaViewModel() {
        mAreaRepository = new AreaRepository(ApplicationHolder.get());
    }

    public LiveData<List<Area>> queryAreasByCity(String key) {

        switch (key) {
            case "台湾":
            case "澳门":
            case "香港":
                return mAreaRepository.queryAreasByProvince(key);
            default:
                return mAreaRepository.queryAreasByCity(key);
        }
    }

    @Override
    protected void onCleared() {
        super.onCleared();
    }

}